#pragma once

#include <string>
#include <fstream>
#include <vector>
#include <gl\glew.h>
//#include <gl\freeglut.h>

#include "FileIO.h"
using namespace std;

// experiment state enumerator
enum ShaderType {Vertex, Fragment};


class CShader
{
public:
	CShader(void);
	~CShader(void);

	// shader management
	void CreateShader();
	bool AttachShader(const string& sShaderSrcFileName_, const ShaderType& eShaderType_);
    void GetShaderSource(const string& sShaderSrcFileName_, const ShaderType& eShaderType_);
    bool CompileShader(const ShaderType& eShaderType_);
	bool LinkShader();
	bool UseShader();
	void DisableShader();
	void DeleteShader();

	// shader information
	void GetUniInfo();
    void GetAttribInfo();
    GLint GetUniLoc(const GLchar *pName_);
    GLint GetAttribLoc(const GLchar *pName_);
	void PrintShaderInfoLog(const GLuint& uShader_);
	void PrintProgramInfoLog();
	//retrievers

private:
	// program
	GLuint  _uProgram;
	// shaders
	GLuint  _uVertexShader;
	GLuint  _uFragmentShader;
	// shader source
	CFileIO _fShaderFile;
	string  _sVertexShaderSource;
	string  _sFragmentShaderSource;

#ifdef _DEBUG
	bool _bDoneValidation;
#endif // _DEBUG
};

#ifdef _DEBUG
	#define CHECK_GL_ERROR() CheckGLError(__FILE__, __LINE__)
	void CheckGLError(char *file, int line);
#else
	#define CHECK_GL_ERROR() 
#endif